﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ResetPassword.aspx.cs" Inherits="KhoaLuan.Account.ResetPassword" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <link href="../Style/bootstrap.min.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="../Style/font-awesome.min.css" rel="stylesheet" type="text/css" media="screen" />
    <!-- SmartAdmin Styles : Please note (smartadmin-production.css) was created using LESS variables -->

    <link href="../Style/smartadmin-production.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="../Style/smartadmin-skins.css" rel="stylesheet" type="text/css" media="screen" />
    <!-- Demo purpose only: goes with demo.js, you can delete this css when designing your own WebApp -->
    <link href="../Style/demo.css" rel="stylesheet" type="text/css" media="screen" />
    <!-- FAVICONS -->
    <link rel="shortcut icon" href="../Images/favicon.ico" type="image/x-icon" />
    <link rel="icon" href="../Images/favicon.ico" type="image/x-icon" />

    <!-- GOOGLE FONT -->
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,300,400,700" />
</head>
<body id="login" class="animated fadeInDown">
    <!-- possible classes: minified, no-right-panel, fixed-ribbon, fixed-header, fixed-width-->
    <header id="header">
        <div style="font-weight: bold; font-size: 30px; float: left; width: 500px !important; margin-top: 10px;">
            HỆ THỐNG QUẢN LÝ
        </div>
        <span id="login-header-space"><span class="hidden-mobile">Cần tài khoản?</span> <a href="register.html" class="btn btn-danger">Tạo tài khoản</a> </span>

    </header>

    <div style="width: 100%;">
        <div style="width: 500px; margin: 0 auto !important;">
            <div class="well no-padding">
                <form id="login-form" class="smart-form client-form">
                    <header>
                        Reset mật khẩu					
                    </header>
                    <fieldset>

                        <section>
                            <label class="label">Nhập mật khẩu mới</label>
                            <label class="input">
                                <i class="icon-append fa fa-envelope"></i>
                                <input type="password" id="txtPassword" />
                                <b class="tooltip tooltip-top-right"><i class="fa fa-envelope txt-color-teal"></i>Nhập mật khẩu mới ở đây</b></label>
                        </section>
                        <section>
                            <label class="label">Nhập lại mật khẩu</label>
                            <label class="input">
                                <i class="icon-append fa fa-user"></i>
                                <input type="password" id="txtConfirmPassword" />
                                <b class="tooltip tooltip-top-right"><i class="fa fa-user txt-color-teal"></i>Nhập lại mật khẩu</b>
                            </label>
                            <div class="note">
                                <a href="/Account/login.aspx">Tôi nhớ mật khẩu</a>
                            </div>
                        </section>
                        <section>
                            <div id="divMes">
                            </div>
                        </section>
                    </fieldset>
                    <footer>
                        <input type="button" class="btn btn-primary" id="btnReset" value="Reset Password" />
                    </footer>
                </form>

            </div>
        </div>
    </div>

    <!--================================================== -->

    <!-- Link to Google CDN's jQuery + jQueryUI; fall back to local -->
    <script src="../Scripts/libs/jquery-2.0.2.min.js"></script>
    <script src="../Scripts/libs/jquery-ui-1.10.3.min.js"></script>

    <!-- BOOTSTRAP JS -->
    <script src="../Scripts/bootstrap/bootstrap.min.js"></script>
    <!-- JQUERY VALIDATE -->
    <script src="../Scripts/plugin/jquery-validate/jquery.validate.min.js"></script>
    <!-- MAIN APP JS FILE -->
    <script src="../Scripts/app.js"></script>
    <script type="text/javascript">
        runAllForms();
        function ShowMes(mes, success) {
            var divmess = $('<div class="alert fade in">');
            divmess.addClass(success ? "alert-success" : "alert-warning");
            divmess.append($('<button class="close" data-dismiss="alert">').text('x')).append(mes);
            $('#divMes').empty().append(divmess);
        }

        $(document).ready(function () {

            $("#btnReset").click(function () {
                if ($("#txtPassword").val() != $("#txtConfirmPassword").val()) {
                    ShowMes("Hai mật khẩu không trùng khớp", false);
                    return;
                }
                debugger;
                $.ajax({
                    type: "POST",
                    url: "ResetPassword.aspx/ResetPass",
                    data: JSON.stringify(
                                {
                                    newpass: $("#txtPassword").val(),
                                }),
                    contentType: "application/json",
                    dataType: "text",
                    success: function (response) {
                        debugger;
                        var obj = JSON.parse(JSON.parse(response).d);
                        if (obj.Status == "Success") {
                            ShowMes("Đổi pass thành công, vui lòng quay lại trang login", true);
                        }
                        else {
                            ShowMes(obj.Cause, false);
                        }
                    }
                });
            });
        });

        function GetQueryString(name) {
            name = name.toLowerCase();
            var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search.toLowerCase());
            return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
        }
    </script>

</body>

</html>
